//index.js——Express 服务器入口文件
//node 后端服务器

const userApi = require('./api/userApi');
const fs = require('fs');
const path = require('path');
const bodyParser = require('body-parser');
const express = require('express');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));

// 后端api路由
app.use('/api/user', userApi);

// 监听端口
app.listen(3000);
console.log('success listen at port:3000......');

//const express = require('express')
//const app = express()
const Router = express.Router()
Router.get('/test', function(req, res) {
     return res.json({
         code: 0,
         data: 'hello world!'
     })
   })

 app.use('/testRouter', Router)

 app.listen(3001, function() {
     console.log('express server is success')
   });
